<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
<%
	String uuid = UUID.randomUUID().toString();
	request.setAttribute("uuid", uuid);
%>
<div class="row">
	<div class="col-md-12">
		<div>
			<div class="box-body">
				<table id="funcPointForRoleGrid_${uuid}">

				</table>
			</div>
			<!-- /.box-body -->
			<div class="box-footer clearfix no-border" id="funcPointForRoleGridTb_${uuid }">
				<button class="btn btn-primary pull-right btn-sm addBtn">
					<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
					选择
				</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(function() {
		var roleId = '${param.roleId}';
		var uuid = '${uuid}';
		var funcPointForRoleGrid = $("#funcPointForRoleGrid_" + uuid);
		var funcPointForRoleGridTb = $("#funcPointForRoleGridTb_" + uuid);
		//功能点定义部分
		funcPointForRoleGrid = funcPointForRoleGrid.bootstrapTable({
			url : ctx + "/funcPointAction/queryFuncPointsNotInRole.do?roleId="
					+ roleId,
			columns : [ {
				field : '_id',
				checkbox : true
			}, {
				title : '功能点名称',
				field : 'name',
				width : 200,
				filterControl : "input"
			}, {
				title : 'URL地址',
				field : 'url',
				width : 300,
				filterControl : "input"
			} ],
			filterControl : true,
			height : $(window).height() * 0.7
		});

		funcPointForRoleGridTb.find(".addBtn").click(
				function() {
					var rows = funcPointForRoleGrid
							.bootstrapTable("getSelections");
					if (!rows || rows.length <= 0) {
						webUtils.alert("请选择数据");
					} else {
						var selected = [];
						$.each(rows, function(i, row) {
							selected.push(row.id);
						});
						top.webUtils.topicPublish("funcPointForRole.selected",
								selected);
					}
				});

	});
</script>